package com.oreilly.learningsparkexamples.scala

import org.apache.hadoop.io.{IntWritable,Text}
import org.apache.spark.SparkContext

/**
  * 加载SequenceFile
  */
object BasicLoadSequenceFile{

  def main(args: Array[String]): Unit = {
    if(args.length<2){
      println("Usage: [sparkmaster] [inputfile]")
      System.exit(1)
    }
    val master = args(0)
    val inputFile = args(1)

    val sc = new SparkContext(master,"BasicLoadSequenceFile")
    val data = sc.sequenceFile(inputFile,classOf[Text],classOf[IntWritable])
      .map{case(x,y) => (x.toString,y.get())
      }
    println(data.collect().toList)
  }

}